// 导出为excel文件

import { connect } from "echarts";

    
/**
 * 
 * @param {*} data 传入的excel数据
 * @param {String} filename  文件名
 */

export const exportExcel = (excelHeader, data, filename) => {
    // 创建 a 标签来下载 Excel
    const a = document.createElement('a');
    // 将表头和数据合并
    const combinedData = [excelHeader, ...data];
    const worksheet = combinedData.map(row => row.join('\t')).join('\n');
    // 设置下载文件名
    a.download = filename || 'test.xls';
    a.href = URL.createObjectURL(new Blob([worksheet], { type: 'application/vnd.ms-excel' }));
    a.click();
    URL.revokeObjectURL(a.href);
    a.remove();
};
